﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Com.CMS263.PO;
using Com.CMS263.BLL;
using Com.CMS263.Util;

namespace Com.CMS263.Web
{
    public partial class userLogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void txtUserId_TextChanged(object sender, EventArgs e)
        {

        }

        protected void ibtnLogin_Click(object sender, ImageClickEventArgs e)
        {
            string uid = StringUtil.checkStr(txtUserId.Text);
            string pwd = StringUtil.checkStr(txtPassword.Text);
            string code = Request["rgCheckCode"];
            string recode = Convert.ToString(Session["code"]);
            if (uid == "" || pwd == "")
            {
                StringUtil.Alert("'用户名或密码不能为空", "-1");
            }
            else if (code == "")
            {
                StringUtil.Alert("请输入验证码", "-1");
            }
            else if (!code.ToLower().Equals(recode.ToLower()))
            {
                StringUtil.Alert("验证码输入错误","-1");
            }
            else
            {
                AdminUserBLL userBLL = new AdminUserBLL();
                if (userBLL.AdminUserLogin(uid, pwd))
                {
                    Response.Redirect("/manage/main.aspx");
                }
                else
                {
                    StringUtil.Alert("登录失败请重试", "-1");
                }

            }
        }
    }
}
